Include import specifiers as references in code lens#2432
Open
darwin808 wants to merge 1 commit intomicrosoft:mainfrom
Open
Include import specifiers as references in code lens#2432darwin808 wants to merge 1 commit intomicrosoft:mainfrom
darwin808 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Previously, for `export function foo()` and `import { foo } from "./a"`,
the import specifier `foo` was not counted as a reference in the code lens.
This caused the reference count to be lower than expected (matching TS 5.x
behavior rather than TS 6.0 behavior).
This fix adds import specifiers to `singleReferences` in `getSearchesFromDirectImports`,
ensuring they are properly counted. Export specifiers are excluded since they are
already handled by `getReferencesAtExportSpecifier`.
Also added deduplication logic to prevent the same node from being added
multiple times when traversing import/export chains.
Fixes microsoft#2367
Author
|
@microsoft-github-policy-service agree |
jakebailey
reviewed
Jan 7, 2026
|
|
||
| // === /b.ts === | ||
| // import B, { B1 } from "./a"; | ||
| // import B, { [|B1|] } from "./a"; |
Member
There was a problem hiding this comment.
Seems wrong, given _submodules/TypeScript/tests/baselines/reference/findAllRefsOfConstructor_multipleFiles.baseline.jsonc does not include it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export function foo()andimport { foo } from "./a", the importfoois now properly counted as a referenceChanges
singleReferencesingetSearchesFromDirectImports(importTracker.go)getReferencesAtExportSpecifiershouldAddSingleReferenceto prevent duplicate entries when traversing import/export chainsgetReferencesAtLocationto handle simple import specifiers (not justimport { foo as bar }patterns)Test plan
foonow shows 4 references (was 3) incodeLensFunctionsAndConstants01testFixes #2367